package org.recursed.simpleweather;


import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class SimpleWeather extends Activity {

	public static final int MENU_ITEM_MANAGE_LOCATIONS = 0;

	private LocationManager locationManager;
	private WeatherGallery weatherGallery;
	private AddLocation addLocation;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.locationManager = new LocationManager(this);
        if (locationManager.getLocationCount() == 0) {
	        setContentView(R.layout.addlocation);
	        this.addLocation = new AddLocation(this);
        } else {
        	setContentView(R.layout.main);
        	this.weatherGallery = new WeatherGallery(this);
        }
    }

    protected LocationManager getLocationManager() {
		return locationManager;
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);
		menu.add(0, MENU_ITEM_MANAGE_LOCATIONS, 0, R.string.manageLocations);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item){
	    switch (item.getItemId()){
	    case MENU_ITEM_MANAGE_LOCATIONS:
	    	setContentView(R.layout.addlocation);
	    	if (addLocation == null) {
	    		addLocation = new AddLocation(this);
	    	}
	        return true;
	    }
	    return false;
	}
    
   
}